Fix life-cycle handling of treeview columns
authorMatthias Clasen <mclasen@redhat.com>
Sat, 22 Feb 2014 03:31:16 +0000 (22:31 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Sat, 22 Feb 2014 03:31:16 +0000 (22:31 -0500)
gtk_tree_view_remove_column was first removing the column from
its list, then call gtk_tree_view_column_unset_tree_view, which
would then call gtk_container_remove to remove its button from
the treeview. But the treeview remove implementation relied
on the column being still in the list in order to recognize
the button as 'special', so in effect the button was never
properly removed and thus, leaked.

Fix this by callling unset_tree_view before removing the
column from the list.

https://bugzilla.gnome.org/show_bug.cgi?id=724891

gtk/gtktreeview.c

index 953f0709d4b3b808209dfd695d9e68596a86eeb9..2e0aa5da0b19d4983e8cdff115e47afb7a863879 100644 (file)
@@ -11923,6 +11923,11 @@ gtk_tree_view_remove_column (GtkTreeView       *tree_view,
 
   position = g_list_index (tree_view->priv->columns, column);
 
+  if (gtk_widget_get_realized (GTK_WIDGET (tree_view)))
+    _gtk_tree_view_column_unrealize_button (column);
+
+  _gtk_tree_view_column_unset_tree_view (column);
+
   tree_view->priv->columns = g_list_remove (tree_view->priv->columns, column);
   tree_view->priv->n_columns--;
 
@@ -11930,7 +11935,6 @@ gtk_tree_view_remove_column (GtkTreeView       *tree_view,
     {
       GList *list;
 
-      _gtk_tree_view_column_unrealize_button (column);
       for (list = tree_view->priv->columns; list; list = list->next)
        {
          GtkTreeViewColumn *tmp_column;
@@ -11948,7 +11952,6 @@ gtk_tree_view_remove_column (GtkTreeView       *tree_view,
     }
 
   _gtk_tree_view_reset_header_styles (tree_view);
-  _gtk_tree_view_column_unset_tree_view (column);
   _gtk_tree_view_accessible_remove_column (tree_view, column, position);
 
   g_object_unref (column);